
$(function(){
    $("#UpCgsupplyrelation").dialog({
        title:"修改",
        btnName:"修改",
        btnBind:function(){
            var params=$("#updateCgsupplyrelation").serializeArray();
            var param="";
            for(var i in params){

                if(i==params.length-1){
                    param+=params[i].name+"="+params[i].value;
                }else{
                    param+=params[i].name+"="+params[i].value+"&";
                }
            }
            console.info(param)


            $.post("base/cgsupplyrelation/updateCgsupplyrelation",param,function (msg) {
                $("#UpCgsupplyrelation").dialog("close");
                $("#table").bootstrapTable("refresh");
                toastr.warning("信息提示",msg);
            },"text")
        }
    });
});


function FormatOperation(value,row,index){
    var peration = "<span class='btn btn-default' onclick='updateCgsupplyrelation("+JSON.stringify(row)+")'><i class='glyphicon glyphicon-edit'></i>详情</span>";
    return peration;
}



function  updateCgsupplyrelation(row) {
   console.info(row)
    $("#updateCgsupplyrelation").setForm(row);
    $("#updateCgsupplyrelation table td[name='supplyCode']").text(row.supplyCode);
    $("#updateCgsupplyrelation table td[name='factory']").text(row.factory);
    $("#updateCgsupplyrelation table td[name='supplyName']").text(row.supply.supplyName);
    $("#updateCgsupplyrelation table td[name='evolution']").text(row.evolution);
    $("#updateCgsupplyrelation table select[name='useFlag']").val(row.useFlag);
    $("#updateCgsupplyrelation table select[name='relation']").val(row.relation);
    $(".modal .modal-body #UpCgsupplyrelation").attr("class","show");
    $("#UpCgsupplyrelation").dialog("open");
}

$("th,td").addClass("text-center");
$("th,td").css({"border":"1px solid #dddddd"});


function searchTjCgsupplyrelation() {
    var param=$("#condition").serializeArray();
    console.info(param)

    var obj={};
    for(var i in param){
        obj[param[i].name]=param[i].value;
    }
    $("#table").bootstrapTable("refresh",{query:obj});

}
